/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "MCDPPacket.h"

// CDP Type
#define CDPT_DeviceId       1
#define CDPT_Address        2
#define CDPT_PortId         3
#define CDPT_Capabilities   4
#define CDPT_Version        5
#define CDPT_Platform       6

#define CDPT_Prefixes       7
#define CDPT_HelloOpt       8

#define CDPT_VtpDomain      9
#define CDPT_NativeVlan     10
#define CDPT_Duplex         11

// 12
// 13

#define CDPT_VoIP_VLANReply 14	// appliance id: Allows the VoIP traffic to be differentiated from other traffic, as by separate VLAN-id (auxiliary VLAN).
#define CDPT_VoIP_VLANQuery 15
#define CDPT_Power          16	// power consumtion: The amount of power a VoIP phone consumes, in milliwatts.
#define CDPT_MTU            17
#define CDPT_TrustBitmap    18
#define CDPT_UntrustedCoS   19
#define CDPT_SystemName     20
#define CDPT_SystemOID      21
#define CDPT_ManagementAddr 22
#define CDPT_Location       23

// CDP Capability
#define CDPC_Router            1
#define CDPC_TransparentBridge 2
#define CDPC_SourceRouteBridge 4
#define CDPC_L2Switch          8
#define CDPC_L3Switch          16
#define CDPC_IGMPSnooping      32
#define CDPC_Repeater          64

class MCDPDecoder
{
private:
	CString FormatStringValue(BYTE*, int);
	CString FormatAddressValue(BYTE*, int);
	CString FormatCapabilitiesValue(BYTE*, int);
	CString FormatNativeVlanValue(BYTE*, int);
	CString FormatVoIPVlanValue(BYTE*, int);
	CString FormatDuplexValue(BYTE*, int);
	CString FormatByteValue(BYTE);
	CString FormatRawData(BYTE*, int);

public:
	MCDPDecoder(void);
	~MCDPDecoder(void);

	CString GetTypeName(WORD);
	CString GetValueName(MTLVRecord*);

	CString FindAndGetTypeValueAsString(MCDPPacket*, WORD);
};
